package org.jix.weblog.module.jwt.config;

import org.springframework.context.annotation.Bean;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Component;

/**
 * @version 1.0
 * @Author Jix
 * @Date 2024/7/21 17:55
 * @注释
 */

@Component
public class PasswordEncoderConfig {
    //PasswordEncoder接口 可以将密码加密为不可逆的哈希值
    @Bean
    public PasswordEncoder passwordEncoder() {
        //自动加盐
        return new BCryptPasswordEncoder();
    }

    public static void main(String[] args) {
        BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
        System.out.println(encoder.encode("admin"));
    }
}
